/** MedicalService */
package domain.records;

import java.io.Serializable;

import org.json.JSONObject;

/** 
 * Service provided by doctor (example: blood work) 
 * @author jessienewman
 * @version 1.0
 */
public class MedicalService implements Serializable{
	
	/** Field serviceId. */
	private int serviceId;
	
	/** Field serviceName. */
	private String serviceName;
	
	/** Field price. */
	private int price;
	
	/** 
	 * creates a new Medical service
	 * @param serviceId id of service for DATABASE
	 * @param serviceName name of service
	 * @param price price of service before insurance
	 */
	public MedicalService(int serviceId, String serviceName, int price){
		
		this.serviceId=serviceId;
		this.serviceName=serviceName;
		this.price=price;
	}
	
	public MedicalService(final JSONObject json) {
		populateFromJSON(json);
	}

	/**
	 * Method getServiceId.
	 * @return int
	 */
	public int getServiceId() {
		return serviceId;
	}

	/**
	 * Method setServiceId.
	 * @param serviceId int
	 */
	public void setServiceId(int serviceId) {
		this.serviceId = serviceId;
	}

	/**
	 * Method getServiceName.
	 * @return String
	 */
	public String getServiceName() {
		return serviceName;
	}

	/**
	 * Method setServiceName.
	 * @param serviceName String
	 */
	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	/**
	 * Method getPrice.
	 * @return int
	 */
	public int getPrice() {
		return price;
	}

	/**
	 * Method setPrice.
	 * @param price int
	 */
	public void setPrice(int price) {
		this.price = price;
	}
	
	/** returns the service name
	
	 * @return string of service name */
	public String toString() {
		return serviceName;
	}
	
	public JSONObject getJSON() {
		final JSONObject json = new JSONObject();
		json.put("price", price);
		json.put("serviceName", serviceName);
		json.put("serviceId", serviceId);
		return json;
	}
	
	public void populateFromJSON(final JSONObject json) {
		setPrice(json.getInt("price"));
		setServiceId(json.getInt("serviceId"));
		setServiceName(json.getString("serviceName"));
	}

}
